/*
* Copyright © 2016-2018 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

@import "~styles/variables.scss";
$namespace-action-bg: #d8d8d8;
$dropdown-border-color: $grey-06;
$namespace-dropdown-color: $grey-08;
$current-namespace-hover-bg: $cdap-white-light;
$namespace-hover-bg: #9b9b9b;
$current-namespace-metadata-hover-bg: $grey-08;
$dark-font: #666666;
$grey-font: #bbbbbb;
$success-color: #7ed321;
$star-color: #373a3c;
$namespace-card-width: 240px;

#header-namespace-dropdown {
  padding-left: 0;
  border-left: 1px solid $dropdown-border-color;
  height: 100%;
}
.namespace-dropdown {
  width: 100%;
  padding: 0;
  font-size: 14px;
  user-select: none;
  display: inline-block;
  line-height: 50px;
  cursor: initial;
  padding-left: 24px;
  padding-right: 24px;

  &.opened,
  &:hover {
    background-color: $grey-06;
  }

  div[disabled] { cursor: not-allowed; }

  .dropdown-toggle { height: 50px; }

  .icon-caret-down {
    line-height: 50px;
    height: 13px;
    width: 13px;
  }

  .namespace-display {
    display: inline-block;
    width: 87%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .current-namespace {
    height: 50px;
    cursor: pointer;
    background: transparent;
    width: 100%;
    border: 0;
    text-align: left;
    padding: 0;
    padding-left: 0;
    color: inherit;
    padding-top: 8px;

    &:hover,
    &:active,
    &:focus {
      outline: none;
    }
    span {
      padding-right: 10px;
    }
    .namespace-text {
      line-height: 16px;
      height: 16px;
      padding-top: 2px;

      div {
        color: inherit;
        font-size: 13px;
        color: $grey-03;
      }
    }

    .namespace-and-caret {
      display: flex;
      align-items: center;

      span {
        line-height: 1.5;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .icon-caret-down {
        margin-left: auto;
        margin-right: 10px;
      }
    }
  }
  .dropdown-menu {
    width: $namespace-card-width;
    left: -24px;
    border-bottom-left-radius: 3px;
    outline: none;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 3px;
    border: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    margin: 0;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);

    div {
      padding: 0 10px;
      line-height: 28px;
    }

    .current-namespace-details {
      padding: 0;
      border-top: 6px solid $namespace-action-bg;
      border-bottom: 3px solid $namespace-action-bg;

      .preferences-saved-message {
        font-size: 12px;
        background-color: $success-color;
        display: flex;
        align-items: center;
        color: white;

        .icon-close {
          margin-left: auto;
          cursor: pointer;
        }
      }

      .current-namespace-metadata {
        height: 80px;
        padding: 0;
        border-bottom: 1px solid $namespace-action-bg;

        .current-namespace-name {
          width: 60%;
          float: left;
          font-weight: bold;
          font-size: 14px;
          color: $dark-font;
          overflow: hidden;
          text-overflow: ellipsis;
        }

        .current-namespace-default {
          float: right;
          height: 28px;

          .default-status {
            color: $grey-font;
            font-size: 9px;
            margin-right: 5px;
          }

          svg {
            cursor: pointer;
            color: $star-color;
          }
        }

        &:hover {
          background-color: $current-namespace-metadata-hover-bg;

          .current-namespace-metrics {
            table {
              background-color: $current-namespace-metadata-hover-bg;
            }
          }
        }
      }

      .current-namespace-metrics {
        table {
          width: 100%;
          background-color: white;

          th,
          td {
            text-align: center;
          }

          th {
            color: $grey-font;
            font-size: 10px;
            font-weight: initial;
            line-height: 20px;

            &:first-of-type {
              width: 30%;
            }

            &:nth-of-type(2) {
              width: 50%;
            }
          }

          td {
            color: $dark-font;
            text-align: center;
            line-height: 8px;
          }

          tbody tr {
            height: 15px;
          }
        }
      }

      .current-namespace-preferences {
        line-height: 20px;
        padding: 0;
        height: 26px;

        .btn-group {
          margin-top: 3px;
          margin-bottom: 3px;
        }

        .btn.btn-sm {
          padding: 0;
          border: none;
        }

        .btn-link {
          text-decoration: none;
          padding: 0;
          vertical-align: top;
        }

        h4 {
          vertical-align: middle;
          > span {
            padding: 0;
            vertical-align: top;
            display: inline-block;
            background: transparent;
            &:hover {
              background: transparent;
            }
          }
        }

        .icon-wrench {
          color: #333333;
          height: 16px;
          width: 16px;

          &.saved-success {
            color: $success-color;
          }
        }
      }
      a {
        text-decoration: none;
      }
    }

    .namespace-list {
      clear: both;
      padding: 0;
      max-height: 200px;
      overflow: auto;

      .namespace-container {
        color: $dark-font;
        background-color: $namespace-dropdown-color;
        border-bottom: 1px solid $namespace-action-bg;

        a.namespace-link {
          color: inherit;
          text-decoration: inherit;
          cursor: auto;
          padding-right: 0;
          display: block;
          font-size: 12px;

          &:hover {
            color: #ffffff;
          }

          .namespace-name {
            width: calc(100% - 13px);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
          }
        }

        .default-ns-section {
          cursor: pointer;
          position: relative;
          .icon-star-o {
            display: none;
          }
        }

        &:hover {
          background-color: $namespace-hover-bg;
          color: #ffffff;
          .icon-star-o {
            display: inline-block;
          }
        }
      }

      .modal-backdrop {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1040;
        background-color: #000000;
        opacity: 0.5;
      }
    }

    .namespace-action {
      padding: 0 10px;
      color: $dark-font;
      background: $namespace-action-bg;
      font-size: 12px;
      cursor: pointer;
      &:hover {
        background-color: $namespace-action-bg;
        color: $dark-font;
      }
    }
  }
}
